<script>
    export default {
        required: function(val) {
            return val ? true : false;
        },
        equals: function(val, val2) {
            return val == val2;
        },
        minSize: function(val, int) {
            return val.length && val.length >= int;
        },
        maxSize: function(val, int) {
            return val.length && val.length <= int;
        },
        min: function(val, int) {
            return val && val >= int;
        },
        max: function(val, int) {
            return val && val <= int;
        },
        integer: function(val) {
            return val.length && /^[\-\+]?\d+$/.test(val);
        },
        number: function(val) {
            return val.length && /^[\-\+]?((([0-9]{1,3})([,][0-9]{3})*)|([0-9]+))?([\.]([0-9]+))?$/.test(val);
        },
        onlyNumber: function(val) {
            return val.length && /^[0-9]+$/.test(val);
        },
        onlyNumberSp: function(val) {
            return val.length && /^[0-9\ ]+$/.test(val);
        },
        onlyLetter: function(val) {
            return val.length && /^[a-zA-Z]+$/.test(val);
        },
        onlyLetterSp: function(val) {
            return val.length && /^[a-zA-Z\ ]+$/.test(val);
        },
        onlyLetterNumber: function(val) {
            return val.length && /^[0-9a-zA-Z]+$/.test(val);
        },
        onlyLetterNumberSp: function(val) {
            return val.length && /^[0-9a-zA-Z\ ]+$/.test(val);
        },
        email: function(val) {
            return val.length && /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test(val);
        },
        phone: function(val) {
            return val.length && /^1[3456789]{1}\d{9}$/.test(val);
        },
        url: function(val) {
            return val.length && /^(https?|http|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(val);
        },
        chinese: function(val) {
            return val.length && /^[\u4E00-\u9FA5]+$/.test(val);
        },
        chinaId: function(val) {
            return val.length && /^[1-9]\d{5}[1-9]\d{3}(((0[13578]|1[02])(0[1-9]|[12]\d|3[0-1]))|((0[469]|11)(0[1-9]|[12]\d|30))|(02(0[1-9]|[12]\d)))(\d{4}|\d{3}[xX])$/.test(val);
        },
        chinaIdLoose: function(val) {
            return val.length && /^(\d{18}|\d{15}|\d{17}[xX])$/.test(val);
        },
        chinaZip: function(val) {
            return val.length && /^\d{6}$/.test(val);
        },
        qq: function(val) {
            return val.length && /^[1-9]\d{4,10}$/.test(val);
        },
        checkChoose: function (val,choose,aim) {
          if(choose == aim ){ //如果选择项和目标项相同，则val 不能为空

            return val?true:false;
          }
          return true;
        },
        range_inRules: function (val,aim) {
          if(val != aim){
            return true;
          }else {
            return false;
          }
        },
        isEmpty:function (val) {
          if(val == undefined || val == null || val == '' || val.length <= 0){
            return true
          }else {
            return false
          }
        },
      appChoosed:function (val,float,int) {
        if(int == 1 && parseFloat(val) < parseFloat(float)){
          return false;
        }else {
          return true
        }
      }
    }

</script>
